package com.lvmama.rhino.service.impl.comment;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.rhino.mapperComment.TagListMapper;
import com.lvmama.rhino.pojo.comment.entity.CommentTag;
import com.lvmama.rhino.service.comment.TagsListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("tagsListService")
@Transactional
public class TagsListServiceImpl implements TagsListService {
    @Autowired
    private TagListMapper tagListMapper;

    @Override
    public PageInfo<CommentTag> findAllTagList(int pageNumber, int pageSize) {
        PageHelper.startPage(pageNumber, pageSize);
        PageInfo<CommentTag> tagPageList = new PageInfo<CommentTag>(
                tagListMapper.findAllTagList());
        return tagPageList;
    }

    @Override
    public int deleteById(String tagId) {
        return tagListMapper.deleteById(tagId);
    }

    @Override
    public void addTag(String tagName, String userName) throws Exception {
        tagListMapper.addTag(tagName, userName);
    }

    @Override
    public void modifyTag(String tagName, String tagId) {
        tagListMapper.modifyTag(tagName, tagId);
    }

}
